<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/jsplib/pubhead.jsp"%>
<%@ page import="net.comm.common.ValueMaping" %>
<%@ taglib uri="/WEB-INF/myTaglib.tld" prefix="tag"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<TITLE>社区管理</TITLE>
	<link href="${cpath}/css/youlin.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<!--外套 start -->
<div class="wrap">
  <!--页首 start -->
	<%@ include file="/menu.jsp"%>
  <!--页首 end -->  
  
  <!--导航面包屑 start -->
  <div class="breadCrumb">
  <div class="breadCrumbNav">当前位置：<a href="${cpath}/users.do?action=main">我的主页</a> >> <a href="${cpath}/shequ_home/villageID_${theForm.villageID}.html">社区广场</a></div>
	<%@ include file="/navf.jsp"%> 
 </div> 
  <!--导航面包屑 end -->
  
  <!--主体 start -->
 <div class="body">
 
  <div class="hotBox1">  
    <div class="hotBox1-left">
      <img src="${cpath}/images/png-0184.png" width="102" height="75" >
        <p class="nav">社区管理</p>
      </div>
    <div class="hotBox1-right">
      <p><a href="javascript:history.go(-1);"><img src="${cpath}/images/icon_32.gif" width="137" height="25" /></a></p>
      <p>&nbsp;</p>    
    </div>
  </div> 
   
 <div class="left-Box6">
  <h3>社区管理</h3>
  <div class="left-Box6-content">
   <div class="left-Box6-content-inner">   
	 <form action="${cpath}/shequ.do" name="theForm"  method="post" enctype="multipart/form-data"  class="frmAddTopic">
       <p>
       <label>社区名称</label>
       <input type="text" name='village' value='${theForm.village}' maxlength="150" class="long"/><FONT color=red>*</FONT>
       </p>
       <p>
         <label>社区简介</label>
         <label>
           <textarea name="info" rows="10" cols="80" >${theForm.info}</textarea>
         </label>
       </p>
       <p><label>所在地区</label>
			<tag:CNPCA name="work_location" id="work_location" pid="0" cid="0" value='${theForm.work_location}'   onchange="getAjaxdata('cnpid',this.value)" onkeydown="catch_keydown(this);" css="w70"/>
			<span id=cnpid style="display:inline">
			<tag:CNPCA name="work_sublocation" pid="${theForm.work_location}" cid="0" value='${theForm.work_sublocation}'  onchange="getAjaxdata('cncid',this.value)" onkeydown="catch_keydown(this);" css="w70"/>
			</span>
			<span id=cncid style="display:inline">
			<tag:CNPCA name="work_area" id="work_area" cid="${theForm.work_sublocation}"  value='${theForm.work_area}' onkeydown="catch_keydown(this);" /><FONT color=red>*</FONT></span>
       </p>
       <p class="btn">
       <a href="javascript:doConfirm();"><img src="${cpath}/images/icon_09.gif" /></a> 
       <a href="javascript:history.go(-1);"><img src="${cpath}/images/icon_33.gif" /></a>
       </p>
       
		<INPUT id=max_file_size type=hidden value=2048152 name=MAX_FILE_SIZE>
		<IMG id=oFileChecker style="WIDTH: 0px; HEIGHT: 0px" onload=check_photo_size()> 
		<!--隐藏域-->
		<input type="hidden" name='villageID'	value='${theForm.villageID}'/>
		<input type="hidden" name='mapXY'		value='${theForm.mapXY}'/>
		<input type="hidden" name='address'		value='${theForm.address}'/>
		<input type="hidden" name='postCode'	value='${theForm.postCode}'/>
		<input type="hidden" name='groupNum'	value='${theForm.groupNum}'/>
		<input type="hidden" name='memberNum'	value='${theForm.memberNum}'/>
		<input type="hidden" name='ctime'		value='${theForm.ctime}'/>
		<input type="hidden" name='userID'		value='${theForm.userID}'/>
		<input type="hidden" name='status'		value='${theForm.status}'/>
		<input type="hidden" name='action'		value='${theForm.action}'/>
     </form>
      </div>
   <div class="clearFloat"></div>
  </div>
</div>
  
    <div class="clearFloat"></div>
 </div> 
 <!--主体 end -->
 
 
 <!--页脚 start -->
	<%@ include file="/foot.jsp"%>
 <!--页脚 end --> 
</div>
<!--外套 end -->

</body>
</html>
<script>

  /**
   * 检查项目资料维护
   */
	function doConfirm()
	{
		var form = document.theForm;

		var village = form['village'];
		var info = form['info'];
		var action = form['action'];

		if(village.value == null||village.value.replace(/(^\s*)|(\s*$)/g,"").length < 1)
  		{
			alert('社区名称不能为空');
			village.select();
			return ;
		}

		var work_location = form['work_location'];
		if(work_location.value == null||work_location.value == ""||work_location.value == "0")
		{
			alert('请选择所在省份');
			work_location.select();
			return ;
		}
		var work_sublocation = form['work_sublocation'];
		if(work_sublocation.value == null||work_sublocation.value == ""||work_sublocation.value == "0")
		{
			alert('请选择所在城市');
			work_sublocation.select();
			return ;
		}

		var work_area = form['work_area'];
		if(work_area.value == null||work_area.value == ""||work_area.value == "0")
		{
			alert('请选择所在区县');
			work_area.select();
			return ;
		}

		var len = info.value.replace(/[^\x00-\xff]/g,"**").length;
		if(len > 340)
		{
			alert('描述长度太长，请少于170个汉字');
			info.select();
			return ;
		}

		form.submit();
	}
	function my_getbyid(id)
	{

		 itm = null;
		 if (document.getElementById)
		 {
				itm = document.getElementById(id);
		 }
		 else if (document.all)
		 {
				itm = document.all[id];
		 }
		 else if (document.layers)
		 {
				itm = document.layers[id];
		 }
		 
		 return itm;
	}

	function check_fileszie(filePicker)
	{
			var patn = /.jpg$|.jpeg$|.gif$/i;  
			if(patn.test(filePicker.value)) {
					img_temp = my_getbyid('oFileChecker');
					img_temp.src = filePicker.value;
			} else {
						alert('您选择的不是合法的图片文件,支持文件格式：.jpg/.jpeg/.gif，请重新选择');
						filePicker.value='';
						return false;
			}
			return true;
	}	
	function check_photo_size()
	{
			img_temp = my_getbyid('oFileChecker');
			var limit = parseInt(my_getbyid('max_file_size').value);
			if (img_temp.fileSize > limit) {
					alert("照片文件过大，请选择2M以下的文件上传");
					return false;
			}
	}
	function getAjaxdata(div,id)
	{

		var xmlHttp;
		start = true;
		try
		{    // Firefox, Opera 8.0+, Safari    
			xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{    // Internet Explorer    
			try
			{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
		var url;
		if(div == "divsecsort" || div ==  "divthisort"){

			url = "${cpath}/param/getproperty.jsp?assortID=3&parentID=" + id ;
			

		}else if(div =="cnpid"){
		
			url = "${cpath}/param/getCnpid.jsp?pid=" + id ;
			my_getbyid("cncid").innerHTML="<select name='work_Area' onkeydown='catch_keydown(this);'></select>";
		}else {

			url = "${cpath}/param/getCncid.jsp?cid=" + id;
		}
		if (start)
		{
			my_getbyid(div).innerHTML='后台取数据……';
			xmlHttp.onreadystatechange=function()
			{
				if(xmlHttp.readyState==4 && xmlHttp.status==200)
				{
					var ret_str = xmlHttp.responseText;
					if(div =="divsecsort"){
						var secsort = "<select name='secsort' onkeydown='catch_keydown(this);'>" +
							ret_str.replace(/(^\s*)|(\s*$)/g,"") + "</select>"
						my_getbyid(div).innerHTML = secsort;

					} else if(div =="divthisort"){
						var secsort = "<select name='thisort' onkeydown='catch_keydown(this);'>" +
							ret_str.replace(/(^\s*)|(\s*$)/g,"") + "</select>"
						my_getbyid(div).innerHTML = secsort;

					}else if(div =="cnpid"){

						var secsort = "<select name='work_sublocation' onkeydown='catch_keydown(this);'" +
							" onChange=\"getAjaxdata('cncid',this.value)\">" + 
							ret_str + "</select>"
						my_getbyid(div).innerHTML = secsort;

					}else{
						var secsort = "<select name='work_Area' onkeydown='catch_keydown(this);'>" +
							ret_str + "</select>"
						my_getbyid(div).innerHTML = secsort;
					}
				}
			}
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}
	}
  /**
   * 根据具体请求设置各个组件状态	
   */
  function showState()
	{
		var action = '${theForm.action}';
		var form = document.theForm;		
		if(action == 'detail')
		{
           
		}
		else if(action == 'modifyPage' || action == 'update')
		{
			form['action'].value = 'update';
		}else{

			form['action'].value = 'add';
		}
	}
	showState();
</script>